#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2021-05-26 9:06 上午
# @Author  : yangdy
# @File    : 2021-05-26.1190.反转每对括号间的子串
# @Software: PyCharmCE
class Solution:
    def reverseParentheses(self, s: str) -> str:
        stack = []
        data = []
        x = ""
        for si in s:
            if si in "()":
                if si == "(":
                    data.append(x)
                    x = ""
                else:
                    u = list(x)
                    u.reverse()
                    x = data.pop() + "".join(u)
            else:
                x += si
        return x
